package com.tanhua.dubbo.api.db;

import com.tanhua.domain.db.UserInfo;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;

/**
 * 用户基础信息服务提供者实现类
 */
@Service
public class UserInfoApiImpl implements UserInfoApi{

    @Autowired
    private UserInfoMapper userInfoMapper;


    /**
     * 保存用户基础信息
     * @param userInfo
     */
    @Override
    public void saveUserInfo(UserInfo userInfo) {
        /*Date nowDate = new Date();
        userInfo.setUpdated(nowDate);
        userInfo.setCreated(nowDate);*/
        userInfoMapper.insert(userInfo);
    }

    /**
     * 根据用户id更新用户头像
     * @param userInfo
     */
    @Override
    public void editUserInfo(UserInfo userInfo) {
        ///userInfo.setUpdated(new Date());
        userInfoMapper.updateById(userInfo);
    }

    /**
     * 根据用户id查询用户基础信息
     * @param myCurrentUserId
     * @return
     */
    @Override
    public UserInfo findUserInfoById(Long myCurrentUserId) {
        return userInfoMapper.selectById(myCurrentUserId);
    }
}
